package org.example.multithreading;


import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Code01_ThreadDemo {
  private static int n = 0;
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        /**
         * 创建线程的方式
         * 继承Thread类
         * 1.重写run方法  2.创建Thread对象 3.调用start方法
         *
         */
//        MyThread01 t1 = new MyThread01();
//        MyThread01 t2 = new MyThread01();
//        t1.setName("t1");
//        t2.setName("t2");
//        t1.start();
//        t2.start();
        MyCallable myCallable = new MyCallable();
        FutureTask<Integer> futureTask = new FutureTask<Integer>(myCallable);
        Thread thread = new Thread(futureTask);
        thread.start();
        System.out.println(futureTask.get());
        thread.wait();


    }
}
